<?php








namespace app\admin\controller;








use app\admin\model\StaffModel;


use app\BaseController;


use app\common\Constants\ErrorCode;


use app\common\traits\ActionRecordTrait;


use think\response\Json;





class Staff extends  ApiCommon


{


    use ActionRecordTrait;


    /**


     * 用于判断权限


     * @permission 无限制


     * @allow 登录用户可访问


     * @author Mr.Li


     * @create 2021-05-26 16:20


     */


    public function initialize()


    {


        $action = [


            'permission' => ['exportcsv','import'],


            'allow' => [


                'synckingdeestock'


            ]


        ];


        event('CheckAuth', $action);


        $request = $this->request;


        $a       = strtolower($request->action());


        if (!in_array($a, $action['permission'])) {


            parent::initialize();


        }


    }


    


    /**


     * 获取店铺员工资源


     * @author ran


     * @date 2021-09-16 14:12


     * mailbox 466180170@qq.com


     */


    public function readAdminStaffList():Json


    {


        $request = $this->request->param();


        $model = new StaffModel();


        $shopIds = $this->getCommonShopIdsCollectByUserType();


        if (empty($request['page']) || empty($request['limit'])) return $this->failed(ErrorCode::SYSTEM_INVALID);


        $res          = $model->getStaffAdminListResource($shopIds,(int)$request['page'],(int)$request['limit'],$request);


        return $this->success($res,'获取资源成功');


    }


    


}